/*
 * @(#)DateTimeJsonDeserializer.java
 * Date 2013-09-13
 * Version 1.0
 * Author Jim Horner
 * Copyright (c)2012
 */


package us.hornerscorners.lamppost.model;

import java.io.IOException;

import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonProcessingException;

import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.JsonDeserializer;

import org.joda.time.DateTime;

import us.hornerscorners.lamppost.utils.UTCDateUtils;


/**
 * Class description
 *
 *
 * @version        v1.0, 2013-09-13
 * @author         Jim Horner
 */
public class DateTimeJsonDeserializer extends JsonDeserializer<DateTime> {

    /**
     * Method description
     *
     *
     * @param jp
     * @param dc
     *
     * @return
     *
     * @throws IOException
     * @throws JsonProcessingException
     */
    @Override
    public DateTime deserialize(JsonParser jp, DeserializationContext dc)
            throws IOException, JsonProcessingException {

        return UTCDateUtils.parseDate(jp.getText(), UTCDateUtils.ISO_DATE_TIME_FORMAT);
    }
}
